<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateQiiCrontabTinyTable extends Migration
{
    /**
     * Schema table name to migrate
     * @var string
     */
    public $set_schema_table = 'qii_crontab_tiny';

    /**
     * Run the migrations.
     * @table qii_crontab_tiny
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable($this->set_schema_table)) return;
        Schema::create($this->set_schema_table, function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id')->comment('ID');
            $table->unsignedInteger('run_id')->default('0')->comment('是否开启计划任务');
            $table->string('key', 30)->default('')->comment('计划任务标识');
            $table->string('title', 50)->default('')->comment('描述');
            $table->string('rule', 20)->default('')->comment('执行时间');
            $table->unsignedInteger('runtime')->default('0')->comment('最后运行时间');
            $table->unsignedSmallInteger('status')->default('0')->comment('上次执行是否成功');
            $table->unsignedInteger('runlimit')->default('0')->comment('单次处理数据条数(如为非数据处理计划则设置为0)');

            $table->unique(["key"], 'key');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
     public function down()
     {
       Schema::dropIfExists($this->set_schema_table);
     }
}
